package com.preknow.Demo4;

public class Master {
    public void cure(Pet pet) {
        if(pet.getHealth()<50){
            pet.toHospital();
            System.out.println("吃药.........");
        }
    }


    public static void main(String[] args) {
        Master master = new Master();

        Pet p = new Dog();
        p.setName("花花");
        p.setHealth(40);
        p.setLove(99);
        master.cure(p);

        Penguin penguin = new Penguin();
        penguin.setName("嘟嘟");
        penguin.setHealth(20);
        penguin.setLove(78);
        master.cure(penguin);
    }

}
